<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>{&SITE_TITLE}</title>
    <link href="__PUBLIC__/admin/css/layout.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../Public/Js/jquery-1.2.6.js" ></script>

    <script type="text/javascript">
      $( function(){
          $( "select[name='sorder']" ).val("{$sorder}");
          $( "select[name='eorder']" ).val("{$eorder}");
          $( "select[name='limit']" ).val("{$limit}");
          });
var ctrl = function(name){
  this.elements = document.getElementsByName('id[]');
  this.length = this.elements.length;
}
ctrl.prototype = {
reverse:function(){
          for(i=0;i<this.length;i++){
            this.elements[i].checked= !this.elements[i].checked;
          }
        },
all:function(){
      for(i=0;i<this.length;i++){
        this.elements[i].checked = true;
      }
    },
unAll:function(){
        for(i=0;i<this.length;i++){
          this.elements[i].checked = false;
        }
      },
toggle:function(obj){
         this[obj.checked ? 'all' : 'unAll']();
       },
del:function(id){
      if(id==undefined){
        id = [];
        for(i=0;i<this.length;i++){
          this.elements[i].checked && id.push(this.elements[i].value);
        }
        id = id.join(',');
      }
      if( confirm( "是否删除心情") ){
        alert( id );
        $.post( '__URL__/doDeleteMini/',{id:id},function(text ){
            if( text == 1 ){
            var id_list = id.split( ',' );   
            for (var j=0 ; j< id_list.length ; j++   ){
            $( 'tr['+'id=\'mini'+id_list[j]+'\']' ).remove(); 
            }
            }else if( text == 2 ){
            $( 'tr['+'id=\'mini'+id+'\']' ).remove(); 
            }else{
            alert( "删除失败" );
            }
            });
      }
    },
edit:function(id){
       alert('您选择了id为:'+id);
     }
}
var c = null;
    </script>
  </head>
  <body>
    <div id="container">
                                    <div class="tab">
                                <ul>
                                        <li> <a  href="__URL__/index/">全局设置</a></li>
                                        <li><a class="on" href="__URL__/minilist/">心情管理</a></li>
                                </ul>
                        </div>

      <form action = "" method="post">
        <table class="tableborder" width="100%">
          <tbody>
            <tr class="top">
              <td class="border" colspan="2"></td>
            </tr>
            <tr>
              <th class="header" colspan="2">查询</th>
            </tr>
            <tr class="label">
              <th>说明</th>
              <th>设置</th>
            </tr>
            <tr class="cell">
              <td class="altbg1">
                <b>用户名:</b>
                <br/>
                <span class="smalltxt">根据用户名查询</span>
              </td>
              <td class="altbg2"><input name="name" class="txt" value="{$name}"/></td>
            </tr>
            <tr class="cell">
              <td class="altbg1">
                <b>用户Id</b>
                <br/>
                <span class="smalltxt">根据用户id</span>
              </td>
              <td class="altbg2"><input name="uid" class="txt" value="{$uid}"/></td>
            </tr>
            <tr class="cell">
              <td class="altbg1">
                <b>心情内容</b>
                <br/>
                <span class="smalltxt">根据心情内容,支持模糊查询。</span>
              </td>
              <td class="altbg2"><input name="content" class="txt" value="{$content}"/></td>
            </tr>
            <tr class="cell">
              <td class="altbg1">
                <b>发表时间</b>
                <br/>
                <span class="smalltxt">根据发表时间(格式YYMMDD),支持YYMM月份搜索,例：2009年5月1号请输入:20090501.2009年5月:200905</span>
              </td>
              <td class="altbg2">开始时间:<input name="stime" class="txt" value="{$stime}"/>
                <br />          
                结束时间:<input name="etime" class="txt" value="{$etime}"/></td>
            </tr>

            <tr class="cell">
              <td class="altbg1">
                <b>结果排序</b>
                <br/>
              </td>
              <td class="altbg2">
                <select name="sorder">
                  <option value = "cTime" selected>时间排序</option>
                  <option value = "id">发布id排序</option>
                  <option value = "name">发布者排序</option>
                </select>
                <select name="eorder">
                  <option value = "DESC" selected>降序</option>
                  <option value = "ASC" >升序</option>
                </select>
                <select name="limit">
                  <option value = "10" selected>每页显示10条</option>
                  <option value = "20">每页显示20条</option>
                  <option value = "30">每页显示30条</option>
                  <option value = "100">每页显示100条</option>
                </select>
              </td>
            </tr>
            <tr>
              <td class="footer" colspan="2">
                <input type="submit" class="submit" value="提交" />
              </td>
            </tr>
          </tbody>
        </table>
      </form>
      <table class="tableborder" width="100%">
        <tbody>
          <tr class="top">
            <td class="border" colspan="6"></td>
          </tr>
          <tr>
            <th class="header" colspan="6">标题</th>
          </tr>
          <tr class="label">
            <th><input type="checkbox" class="checkbox" onclick="c.toggle(this)" />删？</th>
            <th>编号</th>
            <th>用户名</th>
            <th>发帖内容</th>
            <th>发帖时间</th>
            <th>操作</th>
          </tr>
          <volist name = "data" id='vo'>
            <php>$i++</php>
            <tr class="cell altbg1" id="mini{$vo['id']}">
              <td><input type="checkbox" class="checkbox" name="id[]" value="{$vo['id']}" /></td>
              <td>{$i}</td>
              <td>{$vo['name']}</td>
              <td>{$vo['content']}</td>
              <td>{$vo['cTime']|friendlyDate}</td>
              <td><button type="button" onclick="c.edit({$vo['id']})">编辑</button><button type="button" onclick="c.del({$vo['id']})">删除</button></td>
            </tr>
          </volist>
          <tr>
            {$html}
          </tr>
          <tr>
            <td class="footer" colspan="6">
              <button type="button" onclick="c.all()">全选</button>
              <button type="button" onclick="c.unAll()">全不选</button>
              <button type="button" onclick="c.reverse()">反选</button>
              <button type="button" onclick="c.del()">删除</button>
            </td>
          </tr>
          <tr class="bottom">
            <td class="border" colspan="6">&nbsp;</td>
          </tr>
        </tbody>
      </table>
    </div>
    <script type="text/javascript">
      c = new ctrl('id[]');
    </script>
  </body>
</html>
